package com.lhb.aicodemother.service;

import com.lhb.aicodemother.model.dto.chathistory.ChatHistoryQueryRequest;
import com.lhb.aicodemother.model.entity.ChatHistory;
import com.lhb.aicodemother.model.entity.User;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.service.IService;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;

import java.time.LocalDateTime;

/**
 * 对话历史 服务层。
 *
 * @author lihai
 */
public interface ChatHistoryService extends IService<ChatHistory> {
    /*
    * 新增对话历史
    * */
    boolean addChatMessage(Long appId,String message,String messageType,Long userId);

    /*
    * 根据应用id删除历史对话
    * */
    boolean deleteByAppId(Long appId);

    /*
    * 获取查询包装类
    * */
    QueryWrapper getQueryWrapper(ChatHistoryQueryRequest request);

    /*
    * 分页查询--游标查询
    * */
    Page<ChatHistory> listAppChatHistoryByPage(Long appId, int pageSize, LocalDateTime lastCreateTime, User longinUser);


    /*
    * 从数据库中加载历史对话
    * */
    int loadChatHistoryToMemory(Long appId, MessageWindowChatMemory chatMemory,int maxCount);
}
